import 'package:flutter/foundation.dart';

import '../../bean/home/home_article_list_entity.dart';
import '../../bean/mine/collect_list_entity.dart';
import '../../http/api.dart';

///
/// @DIR_PATH：lib/viewmodel/mine
/// @TIME：2024/6/23 11:07
/// @AUTHOR：starr
///
class CollectViewModel with ChangeNotifier {
  List<CollectListDatas>? collectList = [];
  int pageCount = 0;


  //取消收藏
  Future<bool?> unCollect(String articleId, int index) async {
    bool? success = await Api.instance.unMyCollect(articleId);
    if (success == true) {
      collectList?.removeAt(index);
      notifyListeners();
    }
    return success;
  }

  //获取我的收藏列表
  Future getCollectList() async {
    collectList = await Api.instance.getCollectList(pageCount);
    notifyListeners();
  }
}
